package com.ttg.model.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.ttg.common.constant.UNLExportable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * @author zhangHongYuan
 * @description
 * @date 2023/6/8 11:19
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "tbl_app_coupon_vip")
public class VipInfo implements UNLExportable,Serializable {
    private static final long serialVersionUID = 918868890272717787L;

    /**
     * 会员编号（自增主键）
     */
    @TableId(value = "vip_id", type = IdType.AUTO)
    private Long vipId; // todo 这里需改改成下划线模式才行,不然会解析数据有一定概率会报错,问题可能出现在json解析上,但是赶着上线没时间弄了以后再弄


    /**
     * 数仓客户号
     */
    @TableField(value = "vip_cst_sc_id")
    private String vipCstScId;

    /**
     * 客户号
     */
    @TableField(value = "vip_cst_id")
    private String vipCstId;

    /**
     * 客户名称
     */
    @TableField(value = "vip_cst_name")
    private String vipCstName;

    /**
     * 身份证卡号
     */
    @TableField(value = "vip_id_card_no")
    private String vipIdCardNo;

    /**
     * 手机号码
     */
    @TableField(value = "vip_phone_number")
    private String vipPhoneNumber;



    /**
     * 年龄
     */
    @TableField(value = "vip_age")
    private Integer vipAge;

    /**
     * 性别（0未知，1男，2女）
     */
    @TableField(value = "vip_sex")
    private Integer vipSex;



    /**
     * 职业
     */
    @TableField(value = "vip_occupation")
    private String vipOccupation;

    /**
     * 所属地区
     */
    @TableField(value = "vip_address")
    private String vipAddress;



    /**
     * 注册时间
     */
    @TableField(value = "vip_reg_time")
    private LocalDateTime vipRegTime;

    /**
     * 注册方式(0=非渠道，1=渠道)
     */
    @TableField(value = "vip_reg_type")
    private Integer vipRegType;


    /**
     * 注册渠道编号
     */
    @TableField(value = "vip_chl_id")
    private Long vipChlId;

    /**
     * 会员状态 0正常 1冻结
     */
    @TableField(value = "vip_status")
    private Integer vipStatus;

    /**
     * 所属机构
     */
    @TableField(value = "vip_agent_no")
    private String vipAgentNo;

    /**
     * 会员等级
     */
    @TableField(value = "vip_grade")
    private Double vipGrade;

    /**
     * 等级有效期起始时间
     */
    @TableField(value = "vip_grade_start_date")
    private LocalDate vipGradeStartDate;

    /**
     * 会员等级有效期
     */
    @TableField(value = "vip_grade_date")
    private LocalDate vipGradeDate;

    /**
     * 积分余额
     */
    @TableField(value = "vip_integration_amount")
    private Long vipIntegrationAmount;

    /**
     * 主体类型(1.企业2.小微商户3.个人4.访客)
     */
    @JsonProperty("vip_type")
    private Integer vipType;

    /**
     * 主体名称
     */
    @TableField(value = "vip_name")
    private String vipName;

    /**
     * 微信openId
     */
    @TableField(value = "vip_wxopen_id")
    private String vipWxopenId;

    /**
     * 邮箱
     */
    @TableField(value = "vip_email")
    private String vipEmail;

    /**
     * 微信号
     */
    @TableField(value = "vip_wx_number")
    private String vipWxNumber;

    /**
     * 成长值
     */
    @TableField(value = "vip_grow")
    private Integer vipGrow;

    /**
     * 注册来源
     */
    @TableField(value = "vip_reg_source")
    private String vipRegSource;

    /**
     * 出生年月
     */
    @TableField(value = "vip_birthday")
    private LocalDate vipBirthday;
    /**
     * 上期成长值
     */
//    @TableField(value = "vip_ago_grow")
//    private Long vipAgoGrow;

    /**
     * 当前成长值
     */
//    @TableField(value = "vip_now_grow")
//    private Long vipNowGrow;
//

    /**
     * 数据更新时间
     */
    @TableField(value = "update_time")
    private LocalDateTime updateTime;

    /**
     * 等级变化
     */
    @TableField(value = "vip_grade_change")
    private Integer vipGradeChange;


    /**
     * 同getVip_id
     *
     * @return vip_id
     */
    public Long getVipId() {
        return vipId;
    }

    /**
     * 同setVip_id
     *
     * @param vipId
     */
    public void setVipId(Long vipId) {
        this.vipId = vipId;
    }


    @Override
    public String toFieIds(){
        List<String> fieIds = Arrays.asList(
                Objects.isNull(vipId)?"":vipId.toString(),
                Objects.isNull(vipCstScId)?"":vipCstScId.toString(),
                Objects.isNull(vipCstId)?"":vipCstId.toString(),
                Objects.isNull(vipCstName)?"":vipCstName.toString(),
                Objects.isNull(vipIdCardNo)?"":vipIdCardNo.toString(),
                Objects.isNull(vipPhoneNumber)?"":vipPhoneNumber.toString(),
                Objects.isNull(vipAge)?"":vipAge.toString(),
                Objects.isNull(vipSex)?"":vipSex.toString(),
                Objects.isNull(vipOccupation)?"":vipOccupation.toString(),
                Objects.isNull(vipAddress)?"":vipAddress.toString(),
                Objects.isNull(vipRegTime)?"":vipRegTime.toString(),
                Objects.isNull(vipRegType)?"":vipRegType.toString(),
                Objects.isNull(vipChlId)?"":vipChlId.toString(),
                Objects.isNull(vipStatus)?"":vipStatus.toString(),
                Objects.isNull(vipAgentNo)?"":vipAgentNo.toString(),
                Objects.isNull(vipGrade)?"":vipGrade.toString(),
                Objects.isNull(vipGradeStartDate)?"":vipGradeStartDate.toString(),
                Objects.isNull(vipGradeDate)?"":vipGradeDate.toString(),
                Objects.isNull(vipIntegrationAmount)?"":vipIntegrationAmount.toString(),
                Objects.isNull(updateTime)?"":updateTime.toString(),
                Objects.isNull(vipGradeChange)?"":vipGradeChange.toString()
        );
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < fieIds.size(); i++) {
            String fieId = fieIds.get(i);
            if (fieId.contains("|")||fieId.contains("\"")){
                fieId="\""+fieId.replace("\"","\"\"")+"\"";
            }
            sb.append(fieId);
            if (i<fieIds.size()-1){
                sb.append("|");
            }
        }
        return sb.toString();
    }
}
